package com.fl.springcloud.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.cloud.stream.messaging.Sink;
import org.springframework.messaging.Message;
import org.springframework.stereotype.Component;

@Component
@EnableBinding(Sink.class) //开启服务监听
public class StreamListenerController {

    @Value("${server.port}")
    private String serverport;

    @StreamListener(Sink.INPUT) //打开服务监听注释
    public void input(Message<String> message){
        String payload = message.getPayload();
        System.out.println("服务端接收数据：==》"+payload+"\t"+"端口:"+serverport);
    }
}
